package com.dhee.creditcardsystem.controller;

import com.dhee.creditcardsystem.util.DBUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Connection;

@RestController
public class test {

    @Autowired
    private DBUtil dbUtil;

    @GetMapping("/test-db")
    public String testDB() {
        Connection conn = null;
        try {
            conn = DBUtil.getConnection();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        return conn != null ? "连接成功" : "连接失败";
    }
}
